package com.huawei.hianalytics.ab.bc.gh;

import com.huawei.hianalytics.ab.ab.bc;
import com.huawei.hianalytics.ab.bc.kl.de;
import java.io.File;
import java.io.IOException;

public class ab {
    private String ab = bc.ik().getFilesDir().getPath();

    ab() {
    }

    private String ab(String str) {
        File file = new File(bc(str), "hianalytics_" + str);
        if (ab(file)) {
            return de.ab(file);
        }
        String bc = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(com.huawei.hianalytics.ab.bc.ab.bc.ab.RSA);
        de.ab(file, bc);
        return bc;
    }

    private void ab(String str, String str2) {
        File file = new File(bc(str));
        File file2 = new File(bc(str), "hianalytics_" + str);
        if (!file.exists() && file.mkdirs()) {
            com.huawei.hianalytics.ab.bc.ef.ab.bc("ComponentManager", "file directory is mkdirs");
        }
        if (ab(file2)) {
            de.ab(file2, str2);
        } else {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("ComponentManager", "refreshComponent():file is not found,and file is create failed");
        }
    }

    private boolean ab(File file) {
        if (file.exists()) {
            return true;
        }
        try {
            return file.createNewFile();
        } catch (IOException e) {
            com.huawei.hianalytics.ab.bc.ef.ab.cd("ComponentManager", "create new file error!");
            return false;
        }
    }

    private char[] ab(String str, String str2, String str3, String str4) {
        byte[] bc = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(str);
        byte[] bc2 = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(str2);
        byte[] bc3 = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(str3);
        byte[] bc4 = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(str4);
        int length = bc.length;
        if (length > bc2.length) {
            length = bc2.length;
        }
        if (length > bc3.length) {
            length = bc3.length;
        }
        if (length > bc4.length) {
            length = bc4.length;
        }
        char[] cArr = new char[length];
        for (int i = 0; i < length; i++) {
            cArr[i] = (char) (((bc[i] ^ bc2[i]) ^ bc3[i]) ^ bc4[i]);
        }
        return cArr;
    }

    private String bc(String str) {
        return this.ab + "/hms/component/".replace("component", str);
    }

    private boolean bc() {
        long bc = com.huawei.hianalytics.ab.bc.ij.ab.bc(bc.ik(), "Privacy_MY", "assemblyFlash", -1);
        if (-1 != bc) {
            return System.currentTimeMillis() - bc > 31536000000L;
        } else {
            com.huawei.hianalytics.ab.bc.ef.ab.bc("ComponentManager", "First init components");
            return true;
        }
    }

    private String cd() {
        return "f6040d0e807aaec325ecf44823765544e92905158169f694b282bf17388632cf95a83bae7d2d235c1f039b0df1dcca5fda619b6f7f459f2ff8d70ddb7b601592fe29fcae58c028f319b3b12495e67aa5390942a997a8cb572c8030b2df5c2b622608bea02b0c3e5d4dff3f72c9e3204049a45c0760cd3604af8d57f0e0c693cc";
    }

    public String ab() {
        String bc;
        String bc2;
        String bc3;
        String bc4;
        String cd = cd();
        if (bc()) {
            com.huawei.hianalytics.ab.bc.ef.ab.bc("ComponentManager", "refresh components");
            bc = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(com.huawei.hianalytics.ab.bc.ab.bc.ab.RSA);
            ab("aprpap", bc);
            bc2 = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(com.huawei.hianalytics.ab.bc.ab.bc.ab.RSA);
            ab("febdoc", bc2);
            bc3 = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(com.huawei.hianalytics.ab.bc.ab.bc.ab.RSA);
            ab("marfil", bc3);
            bc4 = com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(com.huawei.hianalytics.ab.bc.ab.bc.ab.RSA);
            ab("maywnj", bc4);
            com.huawei.hianalytics.ab.bc.ij.ab.ab(bc.ik(), "Privacy_MY", "assemblyFlash", System.currentTimeMillis());
        } else {
            bc = ab("aprpap");
            bc2 = ab("febdoc");
            bc3 = ab("marfil");
            bc4 = ab("maywnj");
        }
        return com.huawei.hianalytics.ab.bc.ab.bc.ab().ab(ab(bc, bc2, bc3, cd), com.huawei.hianalytics.ab.bc.ab.bc.ab().bc(bc4));
    }
}
